const {md5Encry,send} = require("@common/utils")
const {verifyName} = require("./register.service")

const handleParams = async (ctx,next) => {
  try {
      let result = await verifyName(ctx.request.body.name)
      if(result.length) {
        return send(ctx,200,'-1','用户已存在')
      }

      // md5加密
      const {password} =  ctx.request.body
      ctx.request.body.password = md5Encry(password)
      await next()

  } catch (error) {
    console.log(error);
  }

}

module.exports = {handleParams}